import 'package:flutter/material.dart';
import 'package:sow_app_core/sow_app_core.dart';

import 'novel_detail_page.dart';

class NovelListTile extends StatelessWidget {
  final Novel novel;
  final VoidCallback? onUpdate;
  const NovelListTile({Key? key, required this.novel, this.onUpdate})
      : super(key: key);

  @override
  Widget build(BuildContext context) {
    return ListTile(
      leading: Image.network(novel.cover),
      title: Text(novel.title),
      subtitle: Text(novel.author),
      onTap: () async {
        Navigator.pushNamed(context, NovelDetailPage.routeName,
                arguments: novel.novelId)
            .then((value) {
          if (onUpdate != null) {
            onUpdate!();
          }
        });
      },
    );
  }
}
